package com.dkm.ou.me.persistence.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.dkm.base.db.mybatis.dao.MyBatisQueryDaoImpl;
import com.dkm.ou.me.persistence.dao.ResQueryDao;
import com.dkm.ou.me.persistence.entity.ResPo;

/**
 * 对象功能:资源权限 QueryDao接口的实现
 * 开发公司:唯心六艺软件 - Craft6.cn
 * 开发人员:winston
 * 创建时间:2014-07-21 17:10:20
 */
@Repository
public class ResQueryDaoImpl extends MyBatisQueryDaoImpl<String, ResPo> implements ResQueryDao{

    @Override
    public String getNamespace() {
        return ResPo.class.getName();
    }

	public Integer getMaxDepth() {
		String statement=getNamespace() + ".getMaxDepth";
		Object object = sqlSessionTemplate.selectOne(statement);
		return (Integer)object;
	}

	public List<ResPo> findBySubsysId(String subsysId) {
		//return findByKey("findBySubsysId", b().a("subsysId", subsysId).p());
		return findByKey("findBySubsysId",b().p());
	}

	public List<ResPo> findAllActived() {
		StringBuilder sb = new StringBuilder();
		sb.append("is_actived_='Y'");
		return findByKey("find", b().a("whereSql", sb.toString()).p());
	}

	@Override
	public List<ResPo> findResByUserId(String userId) {
		Map<String, Object> params=new HashMap<String,Object>();
		params.put("userId", userId);
		return findByKey("findResByUserId", params);
	}

	@Override
	public List<ResPo> findResByBelong(String belong) {
		Map<String, Object> params=new HashMap<String,Object>();
		params.put("belong", belong);
		return findByKey("findResByBelong", params);
	}
	
	
}
